/**
* @Description: 解压缩
* @Author: 王燕欣
* @Date: 2024-09-27 14:31
*/
import pako from "pako";

export function UnZip(tmp) {
     let strData = atob(tmp);

    // Convert binary string to character-number array
    let charData = strData.split('').map(function (x) { return x.charCodeAt(0); });
    // Turn number array into byte-array
    let binData = new Uint8Array(charData);
    // // unzip
    return JSON.parse(pako.inflate(binData, { to: 'string' }));

}

export function Zip(tmp) {
  try {
    return btoa(pako.gzip(tmp, {to: "string"}));
  }
  catch{
    return tmp;
  }
}